package com.smarthospital.service.impl;

import com.smarthospital.service.TRTCApiService;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.trtc.v20190722.TrtcClient;
import com.tencentcloudapi.trtc.v20190722.models.DismissRoomRequest;
import com.tencentcloudapi.trtc.v20190722.models.DismissRoomResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * create by sym  2021/7/4 14:41.
 */
@Slf4j
@Service
public class TRTCApiServiceIpml implements TRTCApiService {

    /**
     *
     * @param roomId
     */
    @Override
    public void closeTRTCRoom(String roomId) throws TencentCloudSDKException {

        Credential cred = new Credential("AKIDJWWHm22mHrFOJzQcZHn57uSkmX2HGzRd", "ziCQP9d1qW8d0FOQMBtU1Qhqu9FB0jLe");

        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint("trtc.tencentcloudapi.com");

        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);

        TrtcClient client = new TrtcClient(cred, "ap-guangzhou", clientProfile);

        DismissRoomRequest req = new DismissRoomRequest();
        req.setSdkAppId(1400543485L);
        req.setRoomId(Long.valueOf(roomId));
        DismissRoomResponse resp = client.DismissRoom(req);
        log.info("【腾讯音视频服务】 关闭房间 roomID {} {}",roomId,DismissRoomResponse.toJsonString(resp));
    }
}
